#encoding:utf-8
#pip install flask-script
import time,sys,os,json,datetime
reload(sys)
sys.setdefaultencoding('utf-8')
sys.path.append('mymd')
from flask import Flask,request
#from flask.ext.script import Manager
from mymd import req
app = Flask(__name__)
#manager = Manager(app)

@app.route('/')
def index():
    data= request
    print request.user_agent
    print request.headers.get('Accept-Language')
    print request.headers.get('Accept-Language')[0]
    return '<h1>HelloWorld:%s</h1>'%data

@app.route('/user/<name>')
def user(name):
    return "<h1>hello %s</h1>"%name


if __name__ == "__main__":
    app.run(host='0.0.0.0', port=9000, debug=True, threaded=True)
    #manager.run()
    '''
    python hello.py shell#在flask应用上下文环境中运行python shell，方便测试和调试web环境
    python hello.py runserver#运行flask开发服务器，app.run()
    python hello.py -h#显示帮助信息
    python hello.py runserver --help

　　usage: hello.py runserver [-h] [-t HOST] [-p PORT] [--threaded]
　　[--processes PROCESSES] [--passthrough-errors] [-d]
　　[-r]

    python hello.py runserver -h 0.0.0.0 -p 80#这样就开启了本机的80端口，别的机器可以远程访问了
    '''
